package com.itheima.exception.model;


import lombok.Getter;

//统一响应结果


public class Result<T> {
    @Getter
    private int code;//业务状态码  0-成功  1-失败
    @Getter
    private String message;//提示信息
    @Getter
    private T data;//响应数据


    private Result(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static Result<Void> success() {
        return new Result(200, (String)null, (Object)null);
    }

    public static <T> Result<T> success(T data) {
        return new Result(200, (String)null, data);
    }

    public static Result<Void> failed(int code, String message) {
        return new Result(code, message, (Object)null);
    }

    public Result() {
    }
    public static Result error(String message) {
        return new Result(500, message, null);
    }
}
